<?php

namespace App\Trip\Train;

use App\Models\Train\TrainTripInfo\Repositories\Interfaces\TrainCheckingPortRepositoryInterface;
use App\Models\Train\TrainTripInfo\Repositories\Interfaces\TrainExitingPortRepositoryInterface;

class TrainPorts
{
    /**
     * 火车检票口
     * @param string $train_code
     * @param string $from_code
     * @return string
     */
    static function checking(string $train_code, string $from_code): string
    {
        $repo = app(TrainCheckingPortRepositoryInterface::class);
        return $repo->findOneByTrainAndStation($train_code, $from_code)?->checking_port() ?: "";
    }

    /**
     * 火车出站口
     * @param string $train_code
     * @param string $to_code
     * @return string
     */
    static function exiting(string $train_code, string $to_code): string
    {
        $repo = app(TrainExitingPortRepositoryInterface::class);
        return $repo->findOneByTrainAndStation($train_code, $to_code)?->exiting_port() ?: "";
    }
}